/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SMeterInputConverter.java
 * Created：		2016年8月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.notice.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.common.AAttachment2Converter;
import com.thor.palmmall.rest.common.AOperateInfoConverter;
import com.thor.palmmall.rest.notice.ANotice2;
import com.thor.palmmall.spi.notice.SNotice2;

/**
 * @author wolv
 *
 */
public class ANoticeConverter2 implements Converter<SNotice2, ANotice2> {

  public static ANoticeConverter2 getInstance() {
    if (instance == null)
      instance = new ANoticeConverter2();
    return instance;
  }

  private static ANoticeConverter2 instance;

  private ANoticeConverter2() {
  }

  @Override
  public ANotice2 convert(SNotice2 source) {
    if (source == null)
      return null;

    ANotice2 target = new ANotice2();
    target.setAttachments(
        ConverterUtil.convert(source.getAttachments(), AAttachment2Converter.getInstance()));
    target.setContent(source.getContent());
    target.setRemark(source.getRemark());
    target.setTitle(source.getTitle());
    target.setUuid(source.getUuid());
    target.setValidBeginDate(source.getValidBeginDate());
    target.setValidEndDate(source.getValidEndDate());
    target.setBizState(source.getBizState());
    target.setCategory(source.getCategory());
    target.setReadedCount(source.getReadedCount());
    target.setReaders(ConverterUtil.convert(source.getReaders(), AReaderConverter.getInstance()));
    target.setReceivers(ConverterUtil.convert(source.getReceivers(), AReceiverConverter.getInstance()));
    target.setAbortMsg(source.getAbortMsg());
    target.setVersion(source.getVersion());
    target.setCreateInfo(AOperateInfoConverter.getInstance().convert(source.getCreateInfo()));
    target.setLastModifyInfo(AOperateInfoConverter.getInstance().convert(source.getLastModifyInfo()));
    return target;
  }

}
